<!-- 学员端 -->
<template>
	<view class="top_view">
		<!-- isCoach:{{isCoach}} -->
	</view>
</template>
<script> 
	import { 
		getinstructor,
		getUserinfo
	} from '@/common/api/index.js'
	export default {  
		data() {
			return {
				isCoach:0
			}
		},
		onShow(){
			console.log('1111112');
			this.getInstructorList();
		}, 
		onLoad(options) {
			console.log(options,'options');
			// 存储参数
			if(options!=null&&options!=""){
				uni.setStorageSync('studentQuery',JSON.stringify(options));
			}else{
				uni.setStorageSync('studentQuery',"");
			}
			
			
			
			console.log('111111');
			let visible_o = options.visible;
			let commodity_id_o = options.commodity_id;
			let Coach_id_o = options.Coach_ID;
			if(visible_o){
				uni.setStorageSync('visible',visible_o);
			}
			if(commodity_id_o){
				uni.setStorageSync('commodity_id',commodity_id_o);
			}
			if(Coach_id_o){
				uni.setStorageSync('Coach_ID',Coach_id_o);
			}
		},
		methods: {
			 // 判断是否是教练，跳转的页面不一样的
			 getInstructorList(){
			 	// 获取用户信息，然后判读是不是教练
			 	getUserinfo().then(res=>{
			 		console.log(res,'resgetUserinfo');
			 		if(res.data){
						uni.setStorageSync('user_name', res.data.records[0].username)
			 			// 不是教练
			 			getinstructor({instructor_id:res.data.records[0].id}).then(res2=>{
			 				console.log(res2,'res');
			 				if(res2.status==0){
								uni.setStorageSync('user_cn', res2.data[0].name)
								uni.setStorageSync('Coach_id', res2.data[0].id)
			 					// 是教练
			 					uni.setStorageSync('isCoach',1) 
								uni.navigateTo({
									url: "/pages/student/index/coach",
									fail: function(err) {
										console.log(err,'跳转失败')
									}
								})
			 				}else{
								uni.setStorageSync('user_cn', res.data.records[0].name)
								uni.setStorageSync('Coach_id',0)
			 					// 不是教练
			 					uni.setStorageSync('isCoach',0)
								uni.navigateTo({
									url: "/pages/student/index/student",
									fail: function(err) {
										console.log(err,'跳转失败')
									}
								})
			 				} 
			 			})
			 		}else{
						uni.navigateTo({
							url: "/pages/student/index/student",
							fail: function(err) {
								console.log(err,'跳转失败')
							}
						})
					}
			 		
			 	})
			 	
			 }
		},
	}
</script>
<style lang="scss" scoped>
	// .top_view{
	// 	padding: 5px;
	// }
	.title {
		font-weight: bold;
		padding: 16rpx;
	}

	.line_img {
		width: 42rpx;
		height: 17rpx;
	}

	.empty-img {
		width: 240px;
		height: 180px;
	}

	.item {
		display: flex;
		justify-content: center;
		align-items: center;
		height: 100rpx;
	}

	.item-active {
		background: rgb(204, 204, 204);
	}

	.loading {
		text-align: center;
		padding: 20rpx 0;
	}


	.acticities-item {
		display: flex;
		align-items: center;
		margin-bottom: 10px;
		margin-top: 10px;
		border: 1px solid rgba(0, 0, 0, 0.1);

		.video-img {
			width: 100px;
			height: 100px;
			margin-right: 10px;
			padding: 10px;
		}

		.content-right {
			flex: 1;
			display: flex;
			flex-direction: column;
			justify-content: space-around;

			.item-title {
				font-size: 16px;
				font-weight: bold;
			}

			.item-uptatetime {
				font-size: 12px;
				// color: #888;
				color: #ff0000;
				margin-top: 15rpx;
			}

			.price_back {
				width: 80px;
				background: rgba(244, 134, 0, 0.5);
				border-radius: 5px;
				text-align: center;

			}

			.item-price {
				font-size: 20px;
				color: #ff0000;
				margin-top: 20rpx;
				display: flex;
				justify-content: space-between;
				padding-right: 10px;
			}

			.playback_count {
				padding-left: 20px;
				font-size: 12px;
				color: #888;
				margin-top: 15rpx;
			}

			.item-payunm {
				font-size: 14px;
				color: #888;
				margin-top: 10rpx;
			}
		}

		.share {
			font-size: 12px;
			color: white;
			border-radius: 10px;
			padding: 0px 15px;
			background-color: #409EFF;
			margin-top: 60px;
			width: 100px;
			height: 40px;
			line-height: 40px;
			text-align: end;
			position: absolute;
			right: 0;
		}
	}

	.flex_view {
		margin-top: 10px;
		display: flex;

		.item_flex {
			background-color: rgba(244, 134, 0,1);
			flex: 1;
			margin: 0px 10px;
			.flex_span {
				padding: 0px 10px;
			}
		}
		.item_flex:nth-child(1){
			margin-left: 0px;
		}
		.item_flex:nth-child(2){
			margin-right: 0px;
		}
	}
	.ground_view{
		margin-top: 30px;
		margin-bottom: 10px;
		display: flex;
		.item_ground_view{
			flex: 2;
			margin: 0px 10px;
			border-left: 5px solid rgba(244, 134, 0, 1);
			height: 40px;
			line-height: 40px;
			padding-left: 25px;
			font-weight: 600;
			font-size: 20px;
		}
		.item_flex_button{
			flex: 1;
			height: 40px;
			line-height: 40px;
			background-color: white;
			border: 3px solid #409EFF;
			border-radius: 10px;
			color: #409EFF;
			margin-right: 5px;
		}
	}
	
</style>